﻿using System;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using Nardax.Serialization;

namespace Nardax.Azure.StorageClient
{
    public class CloudQueueClientWrapper : ICloudQueueClient
    {
        private readonly CloudQueueClient _cloudQueueClient;

        public CloudQueueClientWrapper(CloudQueueClient cloudQueueClient)
        {
            _cloudQueueClient = cloudQueueClient;
        }

        public ICloudQueue GetQueueReference(string queueAddress)
        {
            return new CloudQueueWrapper(_cloudQueueClient.GetQueueReference(queueAddress));
        }

        public ICloudQueue<T> GetQueueReferenceWithBinarySerializer<T>(string queueAddress)
        {
            return new BinaryCloudQueueWrapper<T>(_cloudQueueClient.GetQueueReference(queueAddress), new BinarySerializer<T>());
        }

        public ICloudQueue<T> GetQueueReferenceWithXmlSerializer<T>(string queueAddress)
        {
            return new XmlCloudQueueWrapper<T>(_cloudQueueClient.GetQueueReference(queueAddress), new XmlSerializer<T>());
        }

        public TimeSpan ApproximateMessageCountCacheLength { 
            get { return _cloudQueueClient.ApproximateMessageCountCacheLength; }
            set { _cloudQueueClient.ApproximateMessageCountCacheLength = value; }
        }

        public StorageCredentials Credentials
        {
            get { return _cloudQueueClient.Credentials; }
        }

        public RetryPolicy RetryPolicy
        {
            get { return _cloudQueueClient.RetryPolicy; }
            set { _cloudQueueClient.RetryPolicy = value; }
        }

        public TimeSpan Timeout
        {
            get { return _cloudQueueClient.Timeout; }
            set { _cloudQueueClient.Timeout = value; }
        }

        public bool UsePathStyleUris
        {
            get { return _cloudQueueClient.UsePathStyleUris; }
        }
    }
}
